import pika
from RabbitMQClass import get_connection

QUEUE_NAME = 'scrape'
connection = get_connection()
channel = connection.channel()

while True:
    # 这样就根据用户输入来进行消费了
    input()
    method_frame, header, body=channel.basic_get(queue=QUEUE_NAME,auto_ack=True)
    if body:
        # body存在执行消费
        print(f' GET {body}')

# 基本消费者使用
# channel.queue_declare(queue=QUEUE_NAME)
# def callback(ch, method, properties, body):
#     print(f"Get {body}")
#
# # channel basic_consume 进行消费。同时指定回调方法为callback，auto_ack为True （表示自动通知消息队列已经处理了），这是自动消费的
# channel.basic_consume(queue='scrape',
#                       auto_ack=True,
#                       on_message_callback=callback)
# channel.start_consuming()
